## -*- Mode: Makefile; -*-
## vim: set ft=automake :
##
## (C) 2011 by Argonne National Laboratory.
##     See COPYRIGHT in top-level directory.
##

## This is an automake makefile fragment that should be included by:
##
##   include $(top_srcdir)/Makefile.mtest
##
## It provides a "testing" rule that uses runtests, cleanup for summary.xml, and
## adds appropriate includes and linker flags for using the MTest framework.
## The goal is to reduce the amount of boilerplate that needs to exist in each
## Makefile.am

# AM_CPPFLAGS are used for C++ code as well
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
LDADD = $(top_builddir)/util/mtest.o
LDADD += $(top_builddir)/util/mtest_datatype.o
LDADD += $(top_builddir)/util/mtest_datatype_gen.o

## FIXME "DEPADD" is a simplemake concept, which we can handle on a per-target
## prog_DEPENDENCIES variable, but it would be better to figure out the right
## way to do this
##DEPADD = @MPILIBLOC@ $(top_builddir)/util/mtest.o

$(top_builddir)/util/mtest.$(OBJEXT): $(top_srcdir)/util/mtest.c
	(cd $(top_builddir)/util && $(MAKE) mtest.$(OBJEXT))

$(top_builddir)/util/mtest_datatype.$(OBJEXT): $(top_srcdir)/util/mtest_datatype.c
	(cd $(top_builddir)/util && $(MAKE) mtest_datatype.$(OBJEXT))

$(top_builddir)/util/mtest_datatype_gen.$(OBJEXT): $(top_srcdir)/util/mtest_datatype_gen.c
	(cd $(top_builddir)/util && $(MAKE) mtest_datatype_gen.$(OBJEXT))

SUMMARY_BASENAME ?= summary

testing:
	$(top_builddir)/runtests -srcdir=$(srcdir) -tests=testlist \
		-mpiexec=${MPIEXEC} -xmlfile=$(SUMMARY_BASENAME).xml \
		-tapfile=$(SUMMARY_BASENAME).tap -junitfile=$(SUMMARY_BASENAME).junit.xml

CLEANFILES = $(SUMMARY_BASENAME).xml $(SUMMARY_BASENAME).tap $(SUMMARY_BASENAME).junit.xml
